# -*- coding: utf-8 -*-

import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *


class MainWindow(QWidget):

    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent=parent)
        self.setWindowTitle("QSlider示例")
        self.resize(300, 100)

        layout = QVBoxLayout()
        self.l1 = QLabel("Hello PyQt5!")
        self.l1.setAlignment(Qt.AlignCenter)
        layout.addWidget(self.l1)

        self.s1 = QSlider(Qt.Horizontal)
        self.s1.setMinimum(10)
        self.s1.setMaximum(50)
        self.s1.setSingleStep(3)
        self.s1.setValue(20)
        self.s1.setTickPosition(QSlider.TicksBelow)
        self.s1.setTickInterval(5)
        layout.addWidget(self.s1)

        self.s1.valueChanged.connect(self.valueChange)
        self.setLayout(layout)

    def valueChange(self):
        print("Current Slider Value: %d" % self.s1.value())
        size = self.s1.value()
        self.l1.setFont(QFont("Arial", size))


if __name__ == '__main__':
    app = QApplication(sys.argv)
    win = MainWindow()
    win.show()
    sys.exit(app.exec())